package model;

import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;

import javax.imageio.ImageIO;

/**
 * Represents the business logic or data part of the
 * system.
 * 
 * @author Kenny Chong, Dan End, James Ju
 * CSE 333 : User Interface
 * Project HMSystem
 */
public class HMSModel 
{
	// Variables.
	private LoginModel loginModel;
	
	// Test cases.
	private Floor testFloor;
	private Room testRoom;
	private Guests testGuest;
	private BufferedImage guestImage;
	
	private Guests testGuest2;
	private BufferedImage guestImage2;
	
	/**
	 * Initialize the model.
	 */
	public HMSModel()
	{
		loginModel = new LoginModel();
		
		// Initialize testFloor.
		testFloor = new Floor("Test Floor");
		
		Calendar date = Calendar.getInstance();
		
		// Read image.
		try 
		{
			guestImage = ImageIO.read(new File(
					"images/rzhao.jpg"));
			guestImage2 = ImageIO.read(new File("images/cpaul.jpg"));
		} catch (IOException e) {
			e.printStackTrace();
		}

		testRoom = testFloor.getRMList().get(0);
		
		// Initialize a testGuest.
		testGuest = new Guests("Rong Zhao", 123, date.getTime(),
				date.getTime(), guestImage, testRoom, "(719)388-2381");

		// Initialize a testGuest2.
		testGuest2 = new Guests("Chris Paul", 124, date.getTime(),
				date.getTime(), guestImage2, testRoom, "(726)838-2134");

		testRoom.addGuestToRoom(testGuest);
		testRoom.addGuestToRoom(testGuest2);
	}
	
	// Setters and getters.
	/**
	 * helps verify user and password.
	 */
	public boolean vertifyUser(String name, char[] password)
	{
		return loginModel.verifyUser(name, password);
	}
	
	/**
	 * Retrieve test floor.
	 * @return
	 */
	public Floor getCurrentFloor()
	{
		return testFloor;
	}
}
